# 强制停止所有Java进程
Write-Host "停止所有Java进程..." -ForegroundColor Yellow
Get-Process -Name java -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 2

# 清理并编译
Write-Host "清理并编译项目..." -ForegroundColor Yellow
& mvn clean package -DskipTests -f "D:\code\team后端code\le-kang-service\pom.xml"

if ($LASTEXITCODE -ne 0) {
    Write-Host "编译失败！" -ForegroundColor Red
    exit 1
}

# 启动服务
Write-Host "启动后端服务..." -ForegroundColor Green
$JVM_OPTS = "-Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m"
Start-Process javaw -ArgumentList "$JVM_OPTS -jar lekang-admin\target\lekang-admin.jar" -WorkingDirectory "D:\code\team后端code\le-kang-service"

Write-Host "后端服务启动成功！" -ForegroundColor Green

